/**══════════════════════════════════╗
*作    者：songbaobao                                                  ║
*职    业：我以我血荐轩辕                                              ║
*CSND地址：https://blog.csdn.net/weixin_43949535                       ║
**GitHub ：https://github.com/TsinghuaLucky912/My_own_C-_study_and_blog║
**GitEE  ：https://gitee.com/lucky912_admin/code-up_-pat               ║
*═══════════════════════════════════╣
*创建时间：                                                           
*功能描述：                                                            
*                                                                      
*                                                                      
*═══════════════════════════════════╣
*结束时间:                                                           
*═══════════════════════════════════╝
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//              西南\./联大               \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
*/
#include <iostream>
#include <vector>
#include <string.h>
#include <unordered_map>
#include <ctype.h>
#include <queue>
#include <list>
#include <map>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

char mylowwer(char c)
{
	if (c <= 'Z' && c >= 'A')
		return c - 'A' + 'a';
}

char myupper(char c)
{
	if (c <= 'z' && c >= 'a')
		return c + 'A' - 'a';
}

char mydivfunc(char* numArr, int base)
{
	char shangArr[256] = { 0 };
	int len = strlen(numArr);

	if (len == 0)
		return '0';

	bool firstnotzero = true;
	int beichushu = 0, yushu = 0, shang;
	for (int i = 0, j = 0; i < len; ++i)
	{
		beichushu = yushu * 10 + numArr[i] - '0';

		yushu = beichushu % base;
		shang = beichushu / base;

		if (0==shang && firstnotzero)
		{
			/* Nothing to do */
		}
		else
		{
			shangArr[j++] = shang + '0';
			firstnotzero = false;
		}
	}

	strncpy(numArr, shangArr, strlen(shangArr) + 1);
	
	return yushu + '0';
}

int main()
{
#if PAT_B1022
	unsigned int Aint, Bint, Cint;
	int Dint;
	while (~scanf("%d%d%d", &Aint, &Bint, &Dint))
	{
		int result[65] = { 0 };
		int index = 0;
		Cint = Aint + Bint;
		while (Cint != 0)
		{
			result[index++] = (Cint % Dint);
			Cint /= Dint;
		}
		if (index == 0)
		{
			printf("%d\n", result[0]);
		}
		else
		{
			for (int i = index - 1; i >= 0; --i)
			{
				printf("%d", result[i]);
			}
			printf("\n");
		}
	}
#endif	

#if A
	unsigned int Aint, Bint, Cint;
	int Dint;
	while (scanf("%d", &Dint), Dint)
	{
		scanf("%d%d", &Aint, &Bint);
		int result[65] = { 0 };
		int index = 0;
		Cint = Aint + Bint;
		while (Cint != 0)
		{
			result[index++] = (Cint % Dint);
			Cint /= Dint;
		}
		if (index == 0)
		{
			printf("%d\n", result[0]);
		}
		else
		{
			for (int i = index - 1; i >= 0; --i)
			{
				printf("%d", result[i]);
			}
			printf("\n");
		}
	}
#endif

#if B
	char sixteenNum[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' };
	char n[16] = { 0 };
	unsigned int a, b, temp = 0;

	while (~scanf("%d%s%d", &a, n, &b))
	{
		char result[65] = { 0 };
		int index = 0;

		if (a == 10)
		{
			temp = atoi(n);
		}
		else
		{
			int len = strlen(n);
			int product = 1;
			for (int i = len - 1; i >= 0; --i)
			{
				if (isdigit(n[i]))
				{
					temp += (n[i] - '0') * product;
				}
				else
				{
					temp += (mylowwer(n[i]) - 'a' + 10) * product;
				}
				product *= a;
			}
		}

		if (0 == temp)
		{
			printf("0\n");
		}
		else
		{
			while (temp != 0)
			{
				int achar = temp % b;
				result[index++] = myupper(sixteenNum[achar]);

				temp /= b;
			}

			for (int i = index - 1; i >= 0; --i)
			{
				printf("%c", result[i]);
			}
			printf("\n");
		}
	}
#endif

#if C
	char numArr_raw[256] = { 0 };
	char numArr[256] = { 0 };
	
	char result[512] = { 0 };
	while (~scanf("%s", numArr_raw))
	{
		int a = 2, i = 0;
		int product = 1;
		
		int len = strlen(numArr_raw);

		for (int j = 0; j < len; ++j)
		{
			if (numArr_raw[j] != '0')
			{
				strncpy(numArr, numArr_raw + j, strlen(numArr_raw) + 1);
				break;
			}
		}
		do
		{
			result[i++] = mydivfunc(numArr, 2);

		} while (atoi(numArr) != 0);
		
		for (int j = strlen(result) - 1; j >= 0; --j)
		{
			printf("%c", result[j]);
		}
		printf("\n");

		memset(result, 0, 512 * sizeof(char));
	}
#endif

#if D
	int N;
	while (~scanf("%d", &N))
	{
		if (0 == N)
		{
			printf("0\n");
			continue;
		}
		int result[64] = { 0 }, index = 0;
		while (N != 0)
		{
			result[index++] = N % 8;
			N /= 8;
		}

		for (int i = index - 1; i >= 0; --i)
		{
			printf("%d", result[i]);
		}
		printf("\n");
	}
#endif
	return 0;
}
/**
*备用注释：
*
*
*
*/
